#!/bin/sh

if ! which gnuplot > /dev/null 2>&1
then
    echo "gnuplot not found - skipping graph creation" >&2
    exit 1
fi

gnuplot<<EOF
    set terminal postscript eps color enhanced "Helvetica,20"
    set output '../probabilityDensity.eps'
    set decimalsign '.'

    set format x '%g'
    set format y '%.1f'
    set xtics 1 mirror
    set xlabel 'd (m)'
    set ytics 0.1 mirror
    set ylabel 'Probability density function (m^{-3})'
    set key left
    set xrange [1:10]
    set yrange [0:0.6]

    numberDensity = '../postProcessing/numberDensity/10/numberDensity.xy'
    volumeDensity = '../postProcessing/volumeDensity/10/volumeDensity.xy'

    kVConversion = (6/pi)**(1./3.)

    plot '-' w l lc rgb 'black' t 'NDF, Vanni (2000)',\
    '-' w l dt 2 lc rgb 'black' t 'VDF, Vanni (2000)',\
    numberDensity every ::0::12 u (\$1/kVConversion):(\$2*kVConversion) w p pt 1 lc rgb 'black' t 'air1',\
    numberDensity every ::13::22 u (\$1/kVConversion):(\$2*kVConversion) w p pt 5 lc rgb 'black' t 'air2',\
    numberDensity every ::23::30 u (\$1/kVConversion):(\$2*kVConversion) w p pt 9 lc rgb 'black' t 'air3',\
    volumeDensity every ::0::12 u (\$1/kVConversion):(\$2*kVConversion) w p pt 2 lc rgb 'black' t 'air1',\
    volumeDensity every ::13::22 u (\$1/kVConversion):(\$2*kVConversion) w p pt 6 lc rgb 'black' t 'air2',\
    volumeDensity every ::23::30 u (\$1/kVConversion):(\$2*kVConversion) w p pt 10 lc rgb 'black' t 'air3'
    1.000   0.042
    1.460   0.062
    1.950   0.083
    2.403   0.100
    2.775   0.116
    3.109   0.127
    3.562   0.141
    4.015   0.151
    4.475   0.162
    4.876   0.172
    5.270   0.179
    5.700   0.188
    6.035   0.190
    6.436   0.188
    6.777   0.178
    7.163   0.157
    7.416   0.137
    7.705   0.109
    7.980   0.078
    8.285   0.047
    8.589   0.026
    8.953   0.010
    9.228   0.003
    9.495   0.002
    EOF
    0.993   0.000
    0.985   0.002
    1.475   0.003
    1.965   0.005
    2.485   0.010
    2.975   0.020
    3.488   0.032
    3.985   0.055
    4.468   0.084
    4.995   0.123
    5.507   0.176
    6.087   0.240
    6.532   0.289
    6.755   0.309
    7.007   0.326
    7.260   0.324
    7.535   0.305
    7.683   0.284
    7.839   0.252
    8.017   0.215
    8.196   0.172
    8.351   0.137
    8.574   0.090
    8.723   0.065
    8.946   0.037
    9.161   0.021
    9.339   0.013
    9.517   0.006
    9.770   0.004
    9.993   0.002
    EOF
EOF

#------------------------------------------------------------------------------
